package com.gitee.wsl.markdown


import com.gitee.wsl.model.plugin.ModelPlugin
import com.gitee.wsl.model.plugin.createPlugin




/**
 * Class represents a plugin (extension) to Markwon to configure how parsing and rendering
 * of markdown is carried on.
 *
 * @see AbstractMarkwonPlugin
 *
 * @see CorePlugin
 *
 * @see MovementMethodPlugin
 *
 * @since 3.0.0
 */
//interface MarkwonPlugin: ModelPlugin<Markwon,MarkwonConfiguration,MarkwonPlugin> {
//    /**
//     * @see io.noties.markwon.MarkwonPlugin.Registry.require
//     * @since 4.0.0
//     */
////    interface Action<P : MarkwonPlugin> {
////        fun apply(p: P)
////    }
//
//    /**
//     * This method will be called before any other during [Markwon] instance construction.
//     *
//     * @since 4.0.0
//     */
//    //fun configure(registry: MarkwonPluginRegistry)
//
//    /**
//     * Method to configure `org.commonmark.parser.Parser` (for example register custom
//     * extension, etc).
//     */
//    fun configureParser(builder: MutableMarkdownFlavourDescriptor)
//
//    /**
//     * Modify [MarkwonTheme] that is used for rendering of markdown.
//     *
//     * @see MarkwonTheme
//     *
//     * @see MarkwonTheme
//     */
//    //fun configureTheme(builder: MarkwonCategoryTheme)
//
//    /**
//     * Configure [MarkwonConfiguration]
//     *
//     * @see MarkwonConfiguration
//     *
//     * @see MarkwonConfiguration.Builder
//     */
//    fun configureConfiguration(builder: MarkwonConfiguration)
//
//    /**
//     * Configure [io.noties.markwon.MarkwonVisitor] to accept new node types or override already registered nodes.
//     *
//     * @see MarkwonVisitor
//     *
//     * @see MarkwonVisitor.Builder
//     */
//    fun configureVisitor(builder: MarkwonVisitor.Builder)
//
//    /**
//     * Configure [MarkwonSpansFactory] to change what spans are used for certain node types.
//     *
//     * @see MarkwonSpansFactory
//     *
//     * @see MarkwonSpansFactory.Builder
//     */
//    fun configureSpansFactory(builder: MarkwonSpansFactory.Builder)
//
//    /**
//     * Process input markdown and return new string to be used in parsing stage further.
//     * Can be described as `pre-processing` of markdown String.
//     *
//     * @param markdown String to process
//     * @return processed markdown String
//     */
//    fun processMarkdown(markdown: String): String
//
//    /**
//     * This method will be called **before** rendering will occur thus making possible
//     * to `post-process` parsed node (make changes for example).
//     *
//     * @param node root parsed org.commonmark.node.Node
//     */
//    fun beforeRender(node: ASTNode)
//
//    /**
//     * This method will be called **after** rendering (but before applying markdown to a
//     * TextView, if such action will happen). It can be used to clean some
//     * internal state, or trigger certain action. Please note that modifying `node` won\'t
//     * have any effect as it has been already *visited* at this stage.
//     *
//     * @param node    root parsed org.commonmark.node.Node
//     * @param visitor [MarkwonVisitor] instance used to render markdown
//     */
//    fun afterRender(node: ASTNode, visitor: MarkwonVisitor)
//
//    /**
//     * This method will be called **before** calling `TextView#setText`.
//     *
//     *
//     * It can be useful to prepare a TextView for markdown. For example `ru.noties.markwon.image.ImagesPlugin`
//     * uses this method to unregister previously registered [AsyncDrawableSpan]
//     * (if there are such spans in this TextView at this point). Or [CorePlugin]
//     * which measures ordered list numbers
//     *
//     * @param textView TextView to which `markdown` will be applied
//     * @param markdown Parsed markdown
//     */
//    //fun beforeSetText(textView: TextView, markdown: Spanned)
//
//    /**
//     * This method will be called **after** markdown was applied.
//     *
//     *
//     * It can be useful to trigger certain action on spans/textView. For example `ru.noties.markwon.image.ImagesPlugin`
//     * uses this method to register [AsyncDrawableSpan] and start
//     * asynchronously loading images.
//     *
//     *
//     * Unlike [.beforeSetText] this method does not receive parsed markdown
//     * as at this point spans must be queried by calling `TextView#getText#getSpans`.
//     *
//     * @param textView TextView to which markdown was applied
//     */
//    //fun afterSetText(textView: TextView)
//
//    companion object
//}
//
///**
// * Class that extends [MarkwonPlugin] with all methods implemented (empty body)
// * for easier plugin implementation. Only required methods can be overriden
// *
// * @see MarkwonPlugin
// *
// * @since 3.0.0
// */
//abstract class AbstractMarkwonPlugin : MarkwonPlugin {
//    //override fun configure(registry: MarkwonPluginRegistry) {}
//    //override fun configureTheme(builder: MarkwonCategoryTheme) {}
//
//    override fun configureParser(builder: MutableMarkdownFlavourDescriptor) {}
//    //override fun configureConfiguration(builder: MarkwonConfiguration.Builder) {}
//    override fun configureVisitor(builder: MarkwonVisitor.Builder) {}
//    override fun configureSpansFactory(builder: MarkwonSpansFactory.Builder) {}
//    override fun processMarkdown(markdown: String): String {
//        return markdown
//    }
//
//    override fun beforeRender(node: ASTNode) {}
//    override fun afterRender(node: ASTNode, visitor: MarkwonVisitor) {}
//
//    /*override fun beforeSetText(textView: TextView, markdown: Spanned) {}
//    override fun afterSetText(textView: TextView) {}*/
//
//    override fun prepare(block: MarkwonConfiguration.() -> Unit): MarkwonPlugin {
//
//        return this
//    }
//
//    override fun install(plugin: MarkwonPlugin, scope: Markwon) {
//        with(scope.config){
//            configureParser(flavourDescriptor)
//        }
//    }
//}